package com.study.samsung.Control;

import com.study.samsung.Utils.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/isnull")
public class IsNullServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //        Enumeration的对象来得到所有的session中的信息,使用循环遍历,执行 removeAttribute()的session删除操作，
//        最后在跳转到登录页面:
//        HttpSession session = request.getSession();
//        Object obj = session.getAttribute("user");
        Enumeration em = req.getSession().getAttributeNames();
        while (em.hasMoreElements()){
            req.getSession().removeAttribute(em.nextElement().toString());
        }

        resp.sendRedirect("/index");
    }
}
